package org.huawei260.TiKu.ODsuanfa;

import java.util.Arrays;
import java.util.Scanner;
public class B_2023B_3250__固定滑窗_阿里巴巴找黄金宝箱5 { // python100%

//	public class Main {
		public static void main(String[] args) {
			Scanner sc = new Scanner(System.in);

			int[] arr = Arrays.stream(sc.nextLine().split(",")).mapToInt(Integer::parseInt).toArray();
			int k = Integer.parseInt(sc.nextLine());

			System.out.println(getResult(arr, k));
		}

		public static int getResult(int[] arr, int k) {
			int window_sum = 0;

			for (int i = 0; i < k; i++) {
				window_sum += arr[i];
			}

			int ans = window_sum;

			for (int i = 1; i <= arr.length - k; i++) {
				window_sum -= arr[i - 1];
				window_sum += arr[i + k - 1];
				ans = Math.max(ans, window_sum);
			}

			return ans;
		}
	}

	/*
	# 输入获取
arr = list(map(int, input().split(",")))
k = int(input())


# 算法入口
def getResult():
    window_sum = 0

    for i in range(k):
        window_sum += arr[i]

    ans = window_sum

    for i in range(1, len(arr) - k + 1):
        window_sum -= arr[i - 1]
        window_sum += arr[i + k - 1]
        ans = max(ans, window_sum)

    return ans


# 算法调用
print(getResult())
	 */